/*
 * The National Parks Database Project
 * Group: Tyler Simrell, Vladmir Dudnic, Michael Jagielo
 * WelcomePanel.java
 */
package panels;

import gui.MainFrame;

import java.awt.CardLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 * This JPanel class is the welcome screen for the program that prompts the user for whether they are
 * a hiker or maintenance.
 * @author Tyler Simrell
 * @version 5/24/13
 */
@SuppressWarnings("serial")
public class WelcomePanel extends JPanel implements ActionListener
{
	private final String HIKER_BUTTON_TEXT = "I Am A Hiker";
	private final String MAINT_BUTTON_TEXT = "I Am Maintenance";
	
	private CardLayout cards;
	private JPanel cardPanel;
	
	/**
	 * This constructor takes in a reference to the card layout and the JPanel that houses the card layout.
	 * @param passedInCards The card layout for all of the panels.
	 * @param passedInPanel The JPanel that the card layout is on top of.
	 */
	public WelcomePanel(CardLayout passedInCards, JPanel passedInPanel)
	{
		super();
		cards = passedInCards;
		cardPanel = passedInPanel;
		setUp();
	}
	
	/**
	 * This method does much of the heavy lifting in regards to setting up the GUI by setting up all
	 * of the components of the JPanel.
	 */
	private void setUp()
	{
		this.setLayout(null);
		cards.addLayoutComponent(this, MainFrame.WELCOME_PANEL);
		
		JLabel lblNewLabel = new JLabel("Welcome to the National Parks Database");
		lblNewLabel.setFont(new Font("Tempus Sans ITC", Font.PLAIN, 18));
		lblNewLabel.setBounds(254, 11, 324, 29);
		this.add(lblNewLabel);
		
		JLabel lblNewLabel_1 = new JLabel("Are you Maintenance or a Hiker?");
		lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 20));
		lblNewLabel_1.setBounds(261, 82, 304, 105);
		this.add(lblNewLabel_1);
		
		JButton hikerButton = new JButton(HIKER_BUTTON_TEXT);
		hikerButton.setBounds(207, 217, 121, 23);
		hikerButton.addActionListener(this);
		this.add(hikerButton);
		
		JButton maintenanceButton = new JButton(MAINT_BUTTON_TEXT);
		maintenanceButton.setBounds(503, 217, 153, 23);
		maintenanceButton.addActionListener(this);
		this.add(maintenanceButton);
		
		this.add(new LowerPanel(cards, cardPanel, false));
	}

	/**
	 * This method services the buttons "I Am Maintenance" and "I Am A Hiker", 
	 * change the current card depending on which button you press.
	 */
	@Override
	public void actionPerformed(ActionEvent event) 
	{
		JButton eventObject = (JButton)event.getSource();
		
		if(eventObject.getText().equals(HIKER_BUTTON_TEXT))
		{
			cards.show(cardPanel, MainFrame.HIKING_PANEL);
		}
		else if(eventObject.getText().equals(MAINT_BUTTON_TEXT))
		{
			cards.show(cardPanel, MainFrame.MAINTENANCE_PANEL);
		}
	}
	
	
}
